<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div style="width: 100%;">
    <div style="width: 100%;">
      <div style="display: flex; padding: 1px 15px;align-items: center;">
        <span style="margin-left: 10px; font-size: 20px;">技能</span>
        <div style="margin-left: auto;margin-right: auto;" class="search-operation-container">
          <!-- 搜索框 -->
          <ISearch v-if="multipleSelection.length == 0"></ISearch>
          <!-- 操作按钮组 -->
          <div v-else>
            <el-button type="primary" style="background-color: #f1edf0; color: #714B67;">
              {{ "(" + multipleSelection.length + ") 已选取" }}
            </el-button>
            <el-button type="primary">
              <el-icon>
                <Tools />
              </el-icon> &nbsp; 操作
            </el-button>
          </div>
        </div>
      </div>
    </div>
    <!-- 分割线 -->
    <el-divider border-style="dotted" />

    <div style="display: flex; height: 100vh;">
      <!-- 表格列表 -->
      <div style="display: flex;flex-direction: column; height: auto;position: relative; width: 100%;flex: 1;">
        <el-table ref="multipleTableRef" row-key="id" :data="tableData" default-expand-all style="width: 100%"
          @selection-change="handleSelectionChange" v-if="showType == 'list'">
          <el-table-column type="selection" width="55" />
          <el-table-column prop="staffName" label="员工名称" width=400>
            <template #default="props">
              <span v-if="props.row.type && props.row.type == 'group_title'" style="font-weight: 600;"> {{
                props.row.groupName }} &nbsp; <span> ({{ props.row.children.length }}) </span> </span>
              <span v-else> {{ props.row.staffName }} </span>
            </template>
          </el-table-column>
          <el-table-column prop="skillType" label="技能类型" sortable width=450 />
          <el-table-column prop="skillName" label="技能" width=400 />
          <el-table-column prop="skillLevel" label="技能等级" width=400 />
          <el-table-column prop="skillProgress" label="技能进度" />
        </el-table>
        <!-- 分页 -->
        <div style="margin-top: 20px;">
          <IdooPagination :param="initPaginationParam" style="float:right ;margin-right: 25px;"
            @click-call-back="paginationCallBack"></IdooPagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import IdooPagination from '@/components/base/pagination/index.vue'
import { Tools } from '@element-plus/icons-vue'
import ISearch from '@/components/base/search/index.vue'
import { tableDatatTest, buttonGroupData } from './testData';
import IdooButtonGroup from '@/components/base/button/buttonGroup/index.vue'
import type { ButtonGroupStructure } from '@/components/base/button/buttonGroup';
import type { PaginationStructure } from '@/components/base/pagination';
//展示方式  list\card
const showType = ref<string>('list')
//列表勾选得内容
const multipleSelection = ref<[]>([]);
//按钮组数据
const buttonGroupDatas = buttonGroupData;
//分页参数
const initPaginationParam = ref<PaginationStructure>();
//表格勾选
const handleSelectionChange = (val: []) => {
  console.log(val);
  multipleSelection.value = val
}
const tableData = tableDatatTest
const cardData = ref([]);

const paginationCallBack = (obj: object) => {
  console.log(obj);
}

//按钮组回调
const buttonGroupChange = (callbackItem: ButtonGroupStructure) => {
  console.log(callbackItem)
  showType.value = callbackItem.id;
  resetViewData();
}

const resetViewData = () => {
  //清空表格勾选数组
  multipleSelection.value = [];
}
onMounted(async () => {
  //获取模块下的菜单数据；
  //获取登录用户信息
  console.warn(2222)
  const $route = useRoute()
  console.log($route)
  console.log($route.params);
  initPaginationParam.value = {
    pageSize: 80,
    totalNum: 235
  }
  //构造卡片数据
  tableData.map(item => {
    const a = {
      ...item,
    }
    cardData.value.push(a);
  })
});
</script>

<style scoped>
:deep(.el-divider--horizontal) {
  margin: 20px 0px 0px !important;
}

.main-left-area {
  border-right: 1px solid #dcdfe6;
  width: 300px;
  min-height: 400px;
  overflow: outo;
}

.card {
  flex-basis: 400PX;
  /* 考虑 10px 的间隙，每个卡片占 20% 宽度 */
  height: 110px;
  box-sizing: border-box;
}


:deep(.el-card__body) {
  justify-content: normal !important;
  align-items: normal m !important
}

.search-operation-container {
  height: 32px;
  display: flex;
  align-items: center;
}
</style>